<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script>
        let arr = [23,45,32,65,54];
        let result = arr.reduce((tmp, item, index) => {
            // if (index==arr.length-1){         // 最后一次
            //     return (tmp+item)/arr.length;
            // } else{
            //     return tmp+item;
            // }
            return index==arr.length-1 ? (tmp+item)/arr.length : tmp+item;
        });

        alert(result);

    </script>

</head>
<body>

</body>
</html>